package com.qf.dao;

import com.qf.pojo.entity.TbPermission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TbPermissionRepository extends JpaRepository<TbPermission,Integer> {
    @Query(value = "SELECT tp.permission_name FROM" +
            " tb_user tu,tb_role tr,tb_permission tp,tb_user_role tur,tb_role_permission trp" +
            " WHERE tu.id = tur.userid " +
            "AND tur.roleid = tr.id " +
            "AND tr.id = trp.roleid " +
            "AND trp.perid = tp.id " +
            "AND tu.user_username = ?1",nativeQuery = true)
    List<String> findPermissionByUserName(String username);
}
